<template>
  <div>
    <div style="margin-top:50px;color:#333; font-size:18px;font-weight: bolder">登录</div>
    <van-cell-group style="margin-top:50px;">
      <van-field v-model="account" required clearable label="用户名" right-icon="question-o" placeholder="请输入用户名" @click-right-icon="$toast('question')" />
      <van-field v-model="password" type="password" label="密码" placeholder="请输入密码" required />
    </van-cell-group>
    <van-button type="primary" style="margin-top:50px;width:150px;" @click="onLogin">登录</van-button>
  </div>
</template>

<script>
  import http from "../plugins/request";
  export default {
    name: "Index",
    data() {
      return {
        account: "",
        password: "",
      };
    },
    mounted() {},
    methods: {
      onLogin() {
        http.post(
          // ##填空2. 完成【填空2】输入请求链接的路由
          "【填空2】", {
            account: this.account,
            password: this.password
          }).then(r => {
          console.log(r);
          // ##填空3/4. 完成【填空3/4】跳转至index页面
          if ("【填空3】" === 200) {
            this.$toast("登录成功.");
            this.$router.push({
            
              name: "【填空4】"
            })
          }
        }).catch(e => {
          this.$toast.fail("登录失败.");
        });
      }
    }
  };
</script>

<style scoped>

</style>

